package com.sharemarking.wa.platform.utils;


import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 生成订单编号
 * @author kj
 * @date 2017/12/15
 */
public class GeneratingOrderNumberUtil {

    /**
     *
     * @param headStr
     * @param days 当前时间
     * @param num 随机数
     * @return String 编号
     */
    public static String generatingOrderNumber(String headStr,Date days,int num) {
        String charValue = "";
        for (int i = 0; i < num; i++) {
            char c = (char) (RandomUtil.randomInt(0, 10) + '0');
            charValue += String.valueOf(c);
        }
        SimpleDateFormat formatDate = new SimpleDateFormat("yyyyMMddHHmmss");
        String number;
        if(headStr!=null){
            number = headStr + formatDate.format(days) +charValue;
        }else{
            number = formatDate.format(days) +charValue;
        }
        return number;
    }
    
    public static String fenToYuan(int number) {
    	DecimalFormat df = new DecimalFormat("0.00");//格式化小数
    	float yuan = (float)number*0.01f;
    	return df.format(yuan);
    }
    
    public static int yuanToFen(String yuan) {
    	return Math.round(((float)(Math.round(Float.valueOf(yuan)*100))/100)*100);
    }
}
